#include <assert.h>
#include <iostream>
#include "../Skill.h"
#include "../ItemList.h"

void TestSkillsLoad()
{
    ItemList<CSkill> skills;

    skills.LoadItems("skills.dat", '#');
    assert(skills.Count() == 5);
    skills.List();
}

void TestSkillsFind()
{
    ItemList<CSkill> skills;
    skills.LoadItems("skills.dat", '#');
    assert(0 == skills.Index("基本剑法"));
    assert(3 == skills.Index("一字电剑"));
    assert(skills.Index("八卦掌") < 0);
}

void TestSkillShow()
{
    ItemList<CSkill> skills;
    skills.LoadItems("skills.dat", '#');
    // maybe overload operator []
    CSkill &skill = skills[1];
    skill.ShowName();
    std::cout << std::endl;
    skill.ShowDetail();
}

void TestSkillDamage()
{
    ItemList<CSkill> skills;
    skills.LoadItems("skills.dat", '#');
    CSkill &skill = skills[4];
    skill.ShowDetail();
    std::cout << "5级的";
    skill.ShowName();
    std::cout << "威力为" << skill.Damage(5) << std::endl;
}

void TestSkillCost()
{
    ItemList<CSkill> skills;
    skills.LoadItems("skills.dat", '#');
    CSkill &skill = skills[2];
    std::cout << "10级的";
    skill.ShowName();
    std::cout << "内力消耗" << skill.MpCost(10) << std:: endl;
}

int main()
{
    TestSkillsLoad();
    TestSkillsFind();
    TestSkillShow();
    TestSkillDamage();
    TestSkillCost();
    return 0;
}
